import datetime
import jwt

from django.conf import settings
class ToolJWT:
    def getjwt(self,userdata):
        userdata["exp"]=datetime.datetime.utcnow()+datetime.timedelta(hours=48)
        key=settings.SECRET_KEY
        jwt_token=jwt.encode(userdata,key,algorithm="HS256")
        return jwt_token
    def getrjwt(self,userdata):
        userdata["exp"]=datetime.datetime.utcnow()+datetime.timedelta(hours=72)
        key=settings.SECRET_KEY
        jwt_token=jwt.encode(userdata,key,algorithm="HS256")
        return jwt_token

    def decodejwt(self, jwt_token):
        key = settings.SECRET_KEY
        decoded_data = jwt.decode(jwt_token, key, algorithms="HS256")
        return decoded_data

tooljwt=ToolJWT()

